﻿@{
    Layout = "~/_SiteLayout.cshtml";
    Page.Region = RefDataManager.GetRegionLkUpVal();
    Page.IDType = RefDataManager.GetIDTypeLkUpVal();
    Page.Title="File Upload";
    
    
}
@{
    if (IsPost) {
        var fileData = Request.Files[0];
        var destFolder = Request["folder"];
        var fileName = Path.GetFileName(fileData.FileName);
        var fileSavePath = Server.MapPath("~" + destFolder + fileName);
        fileData.SaveAs(fileSavePath);
    }
}
 
<!DOCTYPE html>
 
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <link href="/Styles/uploadify.css" 
          rel="stylesheet" type="text/css" media="screen" />
        <script type="text/javascript" 
          src="/uploadify/jquery-1.4.2.min.js"></script>
        <script type="text/javascript" 
          src="/uploadify/swfobject.js"></script>
        <script type="text/javascript" 
          src="/uploadify/jquery.uploadify.v2.1.4.min.js"></script>
    </head>
    <body>
        <div id="demo">
          
        
            <script type="text/javascript">
                $(function() {
                    $('#file_upload').uploadify({
                        'uploader'       : '/uploadify/uploadify.swf',
                        'script'         : '@Request.FilePath',
                        'cancelImg'      : '/uploadify/cancel.png',
                        'folder'         : '/upload/Activation/',
                        'multi'          : true,
                        'auto'           : true,
                        'fileExt'        : '*.xls;*.gif;*.png',
                        'fileDesc'       : 'Image Files (.XLS .JPG, .GIF, .PNG)',
                        'queueID'        : 'queue',
                        'queueSizeLimit' : 3,
                        'simUploadLimit' : 3,
                        'sizeLimit'   : 102400,
                        'removeCompleted': false,
                        'onSelectOnce'   : function(event,data) {
                            $('#status-message').text(data.filesSelected + ' files have been added to the queue.');
                           
                            },
                        'onAllComplete'  : function(event,data) {
                         
                            $('#status-message').text(data.filesUploaded + ' files uploaded, ' + data.errors + ' errors.');
                             processUploadedFile();
                            }
                           
                    });
                });
                
                function processUploadedFile(){
                    $("#uploadForm").attr("action","/CashCard/UpdateCCForActivation");
                    $("#uploadForm").submit();
                }
            </script>
            <div class="demo-box">
                <div id="status-message">Select some files to upload:</div>
                <div id="queue"></div>
                <input id="file_upload" type="file" name="Filedata" />
            </div>
            <form id="uploadForm"></form>
        </div>
    </body>
</html>